///用于更新匹配出库单 对应的 客户
global class ExWareHouseUpdateSchedulable implements Schedulable{
       global void execute(SchedulableContext sc) {
            List<ExWareHouse__c> eList = new List<ExWareHouse__c>();
            Set<Id> aIds = new Set<Id>();
            for(Account  a :[SELECT Id FROM Account WHERE AccountNumber = 'JKDYKH']){
                aIds.add(a.Id);
            }
           ///查询客户为JKDYKH 的出库单进行更新操作 
           eList = [select Account__c,custcode__c from ExWareHouse__c where Account__c In : aIds];
           ///保存客户编码
           Set<String> accNums = new Set<String>();
           for(ExWareHouse__c e : eList){
                accNums.add(e.custcode__c);
           
           }
           ///查询可以匹配的客户
           Map<String,Id> accountMap = new Map<String,Id>();
           for (Account a :[select Id,AccountNumber from Account where AccountNumber in: accNums]){
                accountMap.put(a.AccountNumber,a.Id);
           }
                  
           ///重新匹配
            for(ExWareHouse__c e : eList){
                if(accountMap.containsKey(e.custcode__c))e.Account__c = accountMap.get(e.custcode__c);
            } 
           
           if(eList.size() > 0)update eList;
       }
}